<!--
 * @Descripttion: 
 * @Version: 1.0
 * @Author: wcl
 * @Date: 2023-11-23 15:30:07
 * @LastEditors: wcl
 * @LastEditTime: 2023-11-24 10:28:02
-->
<template>
    <div>
        <a-drawer v-model:open="modalOpen" :title="moduleTitle" width="60%" placement="right">
            <template #extra>
                <a-space wrap>
                    <a-button type="primary" @click="handelAdd('新增分组')">新建</a-button>
                    <a-button type="primary" danger @click="modalOpen = false">关闭</a-button>
                </a-space>
            </template>
            <a-card>
                <a-table :dataSource="dataSource" :columns="groupingColumns" :pagination="pagination" @change="handleChangeSize">
                    <template #bodyCell="{ column, record }">
                        <template v-if="column.key === 'operate'">
                            <a-space>
                                <a-button type="primary" @click="handelAdd('编辑分组',record)">编辑</a-button>
                                <a-button danger type="primary" @click="handleDisabled(record)">禁用</a-button>
                                <a-button danger type="primary" @click="handleDel(record)">删除</a-button>
                            </a-space>
                        </template>
                    </template>
                </a-table>
            </a-card>
        </a-drawer>
        <addGrouping ref="groupRef"/>
    </div>
</template>
<script setup>
import { ref } from 'vue'
import { groupingColumns } from '../../columns.js'
import addGrouping from './addGrouping.vue'
const modalOpen = ref(false)
const moduleTitle = ref('分组管理')
const total = ref(0)
const pagination = ref({
    current: 1,
    pageSize: 10,
    defaultPageSize: 10,
    total: total.value,
    showSizeChanger: true,
    pageSizeOptions: ['10', '20', '50', '100'],
    showTotal: () => `共 ${total.value} 条`,
})
const groupRef = ref(null)
const open = () => {
    modalOpen.value = true
}
const handelAdd = (titles) => {
    groupRef.value.open(titles)
}
defineExpose({ open })
</script>
